﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Export2IMG
{
    public partial class CMNDTruoc : UserControl
    {        
        private string soCMND;
        private string hoTen;
        private string namSinh;
        private string nguyenQuan;
        private string noiDKHK;
        private string noiDKHK_TS;
        private string ngayCap;
        private string thangCap;
        private string namCap;
        private string noiCap;
        private string imageURL =
            Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()))
            + "/images/ava.jpg";
        
        private static string fontChu = "Courier New";
        private static int fontSize = 18;
        private static Color fontColor =  Color.FromArgb(77, 83, 83);


        public CMNDTruoc()
        {
            InitializeComponent();
        }

        private void CMNDTruoc_Load(object sender, EventArgs e)
        {
            setUI();

            lblSoCMND.Text = SoCMND;
            lblHoTen.Text = HoTen.ToUpper();
            lblNgaySinh.Text = NamSinh;
            lblNguyenQuan.Text = NguyenQuan;
            lblDKHK.Text = NoiDKHK;
            lblDKHK_TS.Text = NoiDKHK_TS;
            /*lblNgayCap.Text = NgayCap;
            lblThangCap.Text = ThangCap;
            lblNamCap.Text = NamCap;
            lblNoiCap.Text = NoiCap;*/
            //load image
            Image image = Image.FromFile(ImageURL);
            pbAnh.Image = image;
            pbAnh.Invalidate();

        }
        
        //========================================
        // Các events.
        //========================================

        private void pbAnh_Click(object sender, EventArgs e)
        {
            string fileName = "";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                fileName = openFileDialog1.FileName;
                Image image = Image.FromFile(fileName);
                pbAnh.Image = image;
                pbAnh.Invalidate();

            }
        }
        
        //========================================
        // Các method.
        //========================================


        /// <summary>
        /// Set font, màu sắc, kích thước cho các label
        /// </summary>
        public void setUI()
        {

            // Màu cho 9 chữ số CMND
            lblSoCMND.ForeColor = Color.FromArgb(192, 4, 79);
            lblSoCMND.Font = new Font("JasmineUPC", 30);

            // Màu chữ cho các thông tin
            // Họ tên
            lblHoTen.ForeColor = fontColor;
            lblHoTen.Font = new Font("Courier New", 18, FontStyle.Bold);
            lblHoTen.Text = lblHoTen.Text.ToUpper();

            // Ngày sinh
            lblNgaySinh.ForeColor = fontColor;
            lblNgaySinh.Font = new Font("Courier New", 18);
            // Nguyên quán
            lblNguyenQuan.ForeColor = fontColor;
            lblNguyenQuan.Font = new Font("Times New Roman", 18);
            // Nơi DKHK
            lblDKHK.ForeColor = fontColor;
            lblDKHK.Font = new Font("Times New Roman", 18);

            // Huyện DKHK
            lblDKHK_TS.ForeColor = fontColor;
            lblDKHK_TS.Font = new Font("Times New Roman", 18);
            /*
            // Mat Sau
            // Ngày cấp
            lblNgayCap.ForeColor = Color.FromArgb(54, 57, 63);
            lblNgayCap.Font = new Font("Times New Roman", 15);

            // Tháng cấp
            lblThangCap.ForeColor = Color.FromArgb(54, 57, 63);
            lblThangCap.Font = new Font("Times New Roman", 15);

            // Năm cấp
            lblNamCap.ForeColor = Color.FromArgb(54, 57, 63);
            lblNamCap.Font = new Font("Times New Roman", 15);

            // Nơi cấp
            lblNoiCap.ForeColor = Color.FromArgb(54, 57, 63);
            lblNoiCap.Font = new Font("Times New Roman", 15); 
            */
        }

        public void SetText(string soCMND, string hoTen, string namSinh, string nguyenQuan,
           string noiDKHK, string noiDKHK_TS, string ngayCap,
           string thangCap, string namCap, string noiCap, string imageURL)
        {
            setUI();

            string url = "";
            if ("".Equals(imageURL) || imageURL == null) {
                url =
                    Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()))
                    + "/images/ava.jpg";
            }

            lblSoCMND.Text = soCMND;
            lblHoTen.Text = hoTen;
            lblNgaySinh.Text = namSinh;
            lblNguyenQuan.Text = nguyenQuan;
            lblDKHK.Text = noiDKHK;
            lblDKHK_TS.Text = noiDKHK_TS;
            /*lblNgayCap.Text = ngayCap;
            lblThangCap.Text = thangCap;
            lblNamCap.Text = namCap;
            lblNoiCap.Text = noiCap;*/
            //load image
            Image image = Image.FromFile(url);
            pbAnh.Image = image;
            pbAnh.Invalidate();
        }

        //========================================
        // Getter Setter
        //========================================

        public string SoCMND
        {
            get { return soCMND; }
            set { soCMND = value; }
        }

        public string HoTen
        {
            get { return hoTen; }
            set { hoTen = value; }
        }

        public string NamSinh
        {
            get { return namSinh; }
            set { namSinh = value; }
        }
        
        public string NguyenQuan
        {
            get { return nguyenQuan; }
            set { nguyenQuan = value; }
        }

        public string NoiDKHK
        {
            get { return noiDKHK; }
            set { noiDKHK = value; }
        }

        public string NgayCap
        {
            get { return ngayCap; }
            set { ngayCap = value; }
        }

        public string NoiCap
        {
            get { return noiCap; }
            set { noiCap = value; }
        }

        public string NoiDKHK_TS
        {
            get { return noiDKHK_TS; }
            set { noiDKHK_TS = value; }
        }

        public string ThangCap
        {
            get { return thangCap; }
            set { thangCap = value; }
        }

        public string NamCap
        {
            get { return namCap; }
            set { namCap = value; }
        }

        public string ImageURL
        {
            get { return imageURL; }
            set { imageURL = value; }
        }

    }
}
